package com.wy.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wy.controller.dto.PetDrugDTO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wy.common.R;

import com.wy.service.IPetDrugService;
import com.wy.entity.PetDrug;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 宠物药物明细表 前端控制器
 * </p>
 *
 * @author 王昭贵
 * @since 2023-04-27
 */
@RestController
@RequestMapping("/pet-drug")
public class PetDrugController {

    @Resource
    private IPetDrugService petDrugService;

    // 新增或者更新
    @PostMapping
    public R save(@RequestBody PetDrug petDrug) {
        petDrugService.saveOrUpdate(petDrug);
        return R.success("");
    }
    /****
     * 根据用户id获取已开药物列表信息
     * @param id
     * @return
     */
    @GetMapping("/bycustomer/{id}")
    public R findMyDrugListByCustomerId(@PathVariable Integer id){
        List<PetDrugDTO> petDrugDTOList = petDrugService.getMyDrugListByCustomerId(id);
        return R.success(petDrugDTOList);
    }



}

